package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/04/01 18:10
 **/
public class Day4_1_Num831 {
    class Solution {
        public String maskPII(String s) {
            if (s.contains(".")) {
                String lowerCase = s.toLowerCase();
                return lowerCase.substring(0,1) + "*****" + lowerCase.substring(lowerCase.indexOf("@")-1);
            } else {
                s = s.replace("+", "")
                        .replace("-", "")
                        .replace("(", "")
                        .replace(")", "")
                        .replace(" ", "");
                int pre = s.length() - 10;
                String res = "***-***-" + s.substring(s.length()-4);
                if (pre == 0) {
                    return res;
                } else if (pre == 1) {
                    return "+*-" + res;
                } else if (pre == 2) {
                    return "+**-" + res;
                } else {
                    return "+***-" + res;
                }
            }
        }
    }
}